package com.lx.others.web;

import com.lx.bean.Result;
import com.lx.dm.entity.User;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("feign")
public class FeignDemoDo {

    // 高版本JDK加@RequestParam()
    @RequestMapping("add")
    int add(@RequestParam("a") int a,
            @RequestParam("b") int b){
        return a+b;
    }


    // 对象属性映射为请求参数名 自动装箱
    @RequestMapping("res")
    Result res(Result r){
        r.setCode(r.getCode() + 1);
        return r;
    }
    // 用户信息通过 请求体body 传递过来
    @RequestMapping("user")
    User user(@RequestBody User user,
              @RequestParam("myname") String myname){
        user.setName(myname);
        return user;
    }

    // RESTful 请求方式的地址参数
    @RequestMapping("hello/{nm}")
    String hello(@PathVariable("nm") String name){
        return "你好" + name;
    }




}
